<template>
  <div class="message-detail">
    <div v-if="detailData" class="container">
      <p class="title">{{detailData.title}}</p>
      <div class="intro">
        <div class="user">{{detailData.nameinfo}}</div>
        <div class="desc">
          <div class="name">{{detailData.send_name}}</div>
          <div class="time">{{detailData.send_date}}</div>
        </div>
      </div>
      <p class="content">{{detailData.msg_content}}</p>
    </div>
    <goback></goback>
  </div>
</template>
<script>
import { messageDetail } from "@/api/message.js";
import Goback from '@/components/goback.vue';
export default {
  components:{
    Goback
  },
    data(){
      return{
        id:'',
        detailData:'',
      }
    },
    mounted(){
      this.id = this.$route.query.id;
      console.log(this.$route.query.id)
      if(this.id){
        this.getData()
      }
    },
    methods:{
      getData(){
        messageDetail({
          msg_id:this.id
        }).then((res)=>{
          console.log(res)
          if(res.status=='success'){
            res.data[0].nameinfo = res.data[0].send_name.slice(0,1);
            this.detailData = res.data[0]
          }
        })
      }
    }
}
</script>
<style lang="less" scoped>
.message-detail {
  background: #F7F9F9;
  min-height: 100vh;
  .container {
    background: #fff;
  }
  .title {
    font-size: 19px;
    color: #313541;
    padding: 19px 15px;
    line-height: 26px;
    margin: 0;
    font-weight: bold;
  }
  .intro {
    display: flex;
    height: 38px;
    padding: 9px 0;
    margin: 0 15px;
    border-bottom: 1px solid #f2f2f2;
    .user {
      width: 38px;
      height: 38px;
      line-height: 38px;
      border-radius: 19px;
      text-align: center;
      font-size: 12px;
      color: #009966;
      background: #CBEAE0;
    }
    .desc {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
      margin-left: 8px;
    }
    .name {
      font-size: 14px;
      color: #313541;
    }
    .time {
      font-size: 12px;
      color: #939DAD;
    }
  }
  .content {
    font-size: 14px;
    color: #313541;
    line-height: 20px;
    letter-spacing: 2px;
    padding: 19px 15px;
    margin: 0;
  }
}
</style>